Abhinav - feat(ki-inventory): add stats endpoint and DB seed script#2166
Abhinav - feat(ki-inventory): add stats endpoint and DB seed script#2166abhinav-TB wants to merge 4 commits into
Conversation
|
Radia731
left a comment
There was a problem hiding this comment.
Hello!
Checked out the feature/ki-inventory-api-connect branch, ran npm install, and successfully executed the seed script (node src/scripts/seedKIInventoryItems.js) to populate the local database.
Started the backend server with npm run dev and tested the new inventory endpoint via Postman. Here are the results (screenshots attached below):
GET (Inventory Stats): Hit the /api/kitchenandinventory/inventory/items/stats endpoint and verified it returned a successful response containing the expected object detailing totalItems, criticalStock, and lowStock. ✅
Summary - This PR is approved and ready for Jae to merge
HemanthNidamanuru
left a comment
There was a problem hiding this comment.
Hi,
Thanks for the work on this! Tested locally, overall looks good.
One observation:
The seed script includes a preserved field but it is missing from the GET /api/kitchenandinventory/inventory/items/stats response. Please confirm if this is intentional or if it needs to be included in the stats endpoint.
kunchalasireesha
left a comment
There was a problem hiding this comment.
Hi Abhinav, it looks like this PR currently has merge conflicts with the base branch. Could you please rebase or merge the latest changes from development into your branch and resolve the conflicts? Once the build passes, I’ll finish the review.
Hi Hemanth, Thanks for the catch. I've updated the getInventoryStats controller to calculate and include the preserved count so it now matches the seed script's summary output. I've also merged the latest development branch into this feature branch |
|





Description
Implements # Kitchen Inventory - API Connectivity
Related PRs (if any):
Frontend branch:
feature/ki-inventory-api-connectOneCommunityGlobal/HighestGoodNetworkApp#5142
Main changes explained:
src/scripts/seedKIInventoryItems.js— Script to seed the local MongoDB with sample inventory data (equipment, ingredients, seeds, etc.) and calculate expiration dates for testing preserved items logic.src/controllers/kitchenandinventory/KIInventoryController.js— Added thegetInventoryStatsfunction to query the database and calculate total items, critical stock count, and low stock count based on current vs target thresholds.src/routes/kitchenandinventory/KIInventoryRouter.js— Exposed theGET /inventory/items/statsroute for the frontend to consume.How to test:
feature/ki-inventory-api-connectin theHGNRestrepository.npm installnode src/scripts/seedKIInventoryItems.jsnpm run devto start the backend server.GET http://localhost:4500/api/kitchenandinventory/inventory/items/statsin Postman.totalItems,criticalStock, andlowStock.Screenshots or videos of changes:
Note: